<template>
    <view class="container">
        <Empty v-if="itemList.length === 0"></Empty>
        <!-- 帖子 -->
        <PostCard v-for="(item, index) in itemList" :key="index" v-if="folder.type == 0" :item="item"></PostCard>
        <!-- 八股 -->
        <InterviewCard v-for="(item, index) in itemList" :key="index" v-if="folder.type == 1" :item="item">
        </InterviewCard>
        <!-- 题目 -->
        <WrittenCard v-for="(item, index) in itemList" :key="index" v-if="folder.type == 2" :item="item"></WrittenCard>    </view>


</template>
<script setup lang="ts">
import Empty from '@/components/Empty.vue';
import PostCard from '@/components/PostCard.vue';
import InterviewCard from '@/components/InterviewCard.vue'
import WrittenCard from '@/components/WrittenCard.vue'
import { onLoad, onShow } from '@dcloudio/uni-app';
import { onMounted, reactive, ref } from 'vue';
import { API_getCollection, API_removeFolder, API_updateFolderName } from '@/service/favorite';
import type { DetailArticle } from '@/type/article';
import type { interviewItem } from '@/type/interview'
let folder = ref({
    id: 0,
    title: "",
    type: -1
})

const itemList = ref<DetailArticle[] | interviewItem[]>([]);
onMounted(() => {
    wx.setNavigationBarTitle({
        title: folder.value.title
    })
})
onLoad(async (options) => {
    folder.value = JSON.parse(decodeURIComponent(options?.folder));
    const res = await API_getCollection(folder.value.id);
    itemList.value = res.data;
})
onShow(async () => {
    const res = await API_getCollection(folder.value.id);
    itemList.value = res.data;
    console.log(res.data);
})

</script>
<style scoped lang="scss">
.container {
    padding: 20rpx;

    .header {
        display: flex;
        justify-content: space-between;

        .title {
            font-size: 30rpx;
            color: #333;
        }

    }

}
</style>
